extends base

block vars
  - var title = 'Log In'
  - var description = 'Log into your account!'
  - var bodytag = 'login'
  - var socialProviders = stormpathConfig.web.social

block body

  .container.custom-container
    .va-wrapper
      .view.login-view.container
        if organization
          .header.text-center #{organization.name}
        if status
          .box.row
            .email-password-area.col-xs-12.large.col-sm-12
              .header
                if status === 'unverified'
                  span.
                    Your account verification email has been sent!
                  p.
                    Before you can log into your account, you need to activate your
                    account by clicking the link we sent to your inbox.
                  p.
                    Didn't get the email? <a href="#{stormpathConfig.web.verifyEmail.uri}">Click Here</a>.
                  br
                if status === 'verified'
                  span.
                    Your Account Has Been Verified
                  p.
                    You may now login.
                if status === 'created'
                  span.
                    Your Account Has Been Created
                  p.
                    You may now login.
                if status === 'reset'
                  span.
                    Password Reset Successfully
                  p.
                    You can now login with your new password.
                  br
                if status === 'forgot'
                  span.
                    Password Reset Requested
                  p.
                    If an account exists for the email provided, you will
                    receive an email shortly.
          br
        .box.row
          if hasSocialProviders
            - var cls = 'small col-sm-8'
          else
            - var cls = 'large col-sm-12'

          div(class='email-password-area col-xs-12 #{cls}')
            .header
              if stormpathConfig.web.register.enabled
                span.
                  Log In or <a href="#{stormpathConfig.web.register.uri}">Create Account</a>
              else
                span.
                  Log In

            if error
              .alert.alert-danger.bad-login
                p #{error}

            if formErrors
              .alert.alert-danger.bad-login
                each error in formErrors
                  p #{error.error}

            form.login-form.form-horizontal(method='post', role='form', action=formActionUri)
              input(name='_csrf', type='hidden', value=csrfToken)

              each field, fieldName in formModel.fields
                div(class='form-group group-' + field.name)
                  label(
                    class='col-sm-' + (hasSocialProviders ? 12 : 4),
                    for='#{field.name}'
                  ) #{field.label}

                  div(class='col-sm-' + (hasSocialProviders ? 12 : 8))
                    - var isLoginField = field.name === 'login';
                    input.form-control(
                      id=field.name,
                      name=field.name,
                      type=field.type,
                      placeholder=field.placeholder,
                      autofocus=isLoginField ? 'true' : 'false',
                      required=field.required ? 'true' : 'false',
                      value=form.data && isLoginField ? form.data[field.name] : ''
                    )

              div
                button.login.btn.btn-login.btn-sp-green(type='submit') Log In

          if hasSocialProviders
            .social-area.col-xs-12.col-sm-4
              .header &nbsp;
              label Easy 1-click login:
              if socialProviders.facebook && socialProviders.facebook.enabled
                include facebook_login_form.jade
              if socialProviders.google && socialProviders.google.enabled
                include google_login_form.jade
              if socialProviders.linkedin && socialProviders.linkedin.enabled
                include linkedin_login_form.jade
              if socialProviders.github && socialProviders.github.enabled
                include github_login_form.jade

        if stormpathConfig.web.verifyEmail.enabled
          a.forgot(style="float:left", href="#{stormpathConfig.web.verifyEmail.uri}") Resend Verification Email?
        if stormpathConfig.web.forgotPassword.enabled
          a.forgot(style="float:right", href="#{stormpathConfig.web.forgotPassword.uri}") Forgot Password?
